package com.segersten.othello.service;

import com.segersten.othello.service.akka.Factory;
import com.segersten.othello.service.akka.InMemorySingleInstanceCache;
import com.segersten.othello.service.akka.InMemorySingleInstanceCacheFactory;
import com.segersten.othello.service.rest.JettyUtil;
import com.segersten.othello.service.rest.LocalFileAuthenticateServiceFactory;

public class Boot
{

    private static final String CONFIG_AUTH_CONF = "config/auth.conf";
    InMemorySingleInstanceCache gc;

    public void startup()
    {
        try {
            Factory.setGamePoolObjectFactory(new InMemorySingleInstanceCacheFactory());
            Factory.setAuthenticationServiceFactory(new LocalFileAuthenticateServiceFactory(CONFIG_AUTH_CONF));
            InMemorySingleInstanceCache gc = (InMemorySingleInstanceCache) Factory.getGamePoolObjectFactory().create();
            JettyUtil.start("jetty-server.xml");
        } catch (Exception e) {
            throw new RuntimeException("Failed to boot", e);
        }
    }

    public static void main(String[] args)
    {
        new Boot().startup();
    }

}
